<template>
  <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="896"   >
    <SsGroupTransfer v-bind:targetGroup="groupid" v-bind:groupName="groupname" v-bind:departmentId="departmentId"></SsGroupTransfer>
  </BasicModal>
  <!-- 表单区域 -->

</template>

<script lang="ts" setup>
  import {ref, computed, unref, reactive} from 'vue';
  import {BasicModal, useModal, useModalInner} from '/@/components/Modal';
  import {BasicForm, FormSchema, useForm} from '/@/components/Form/index';
  import {defHttp} from "/@/utils/http/axios";

  import { ActionItem, BasicColumn, BasicTable, TableAction } from '/@/components/Table';
  import { useListPage } from '/@/hooks/system/useListPage';
  import {useMessage} from "/@/hooks/web/useMessage";
  import {formSchema} from '../SsPersonGroup.data';

  import {columns, searchFormSchema, superQuerySchema} from '../../person/SsPerson.data';
  import {
    listGroupPerson,
  } from '../SsPersonGroup.api';
  import SsGroupTransfer from "@/views/baseinfo/persongroup/components/SsGroupTransfer.vue";
  import {onMountedOrActivated} from "@/hooks/core/onMountedOrActivated";

  const { createMessage, createErrorModal } = useMessage();
  const [registerModal1, {openModal}] = useModal();


  // 列表页面公共参数、方法
  const { tableContext } = useListPage({
    designScope: 'basic-table-demo-ajax',
    tableProps: {
      title: '用户列表',
      api: listGroupPersonA,
      columns: columns,
      formConfig: {
        labelWidth: 60,
        schemas: searchFormSchema,
        autoSubmitOnEnter:false,
        showAdvancedButton:true,
        fieldMapToNumber: [
        ],
        fieldMapToTime: [
        ],
      },
      actionColumn: {
        width: 120,
      },
    },
  });
  //BasicTable绑定注册
  const [registerTable,{getCacheColumns,getTableRef,getDataSource,reload},{ rowSelection, selectedRowKeys }] = tableContext;


  // Emits声明
  const emit = defineEmits(['register','success']);
  const isUpdate = ref(false);
  const planModel = reactive({ });
  //表单配置
  const [registerForm, {setProps,resetFields, setFieldsValue, validate,updateSchema,getFieldsValue}] = useForm({
    labelWidth: 160,
    schemas: formSchema,
    showActionButtonGroup: false,
    baseColProps: {span: 12}
  });
  const groupid = ref();
  const departmentId = ref();
  const groupname = ref();
  //表单赋值
  const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
    console.log(data)
    groupid.value = data.select[0].id;
    groupname.value = data.select[0].name;
    departmentId.value = data.select[0].departmentId;
    console.log(groupid)
    console.log(groupname)
    console.log(departmentId)

    setModalProps({confirmLoading: false,showCancelBtn:false,showOkBtn:false});
  });

  //设置标题
  const title = "分组人员列表";//computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
  const { createConfirm } = useMessage();


  async function listGroupPersonA(){
    let params = {};
    console.log(groupid)
    params.groupId = groupid.value;
    console.log(params)
    return await listGroupPerson(params);
  }

  /**
   * 操作栏
   */
  function getTableAction(record){
    return [
      {
        label: '详情',
        onClick: handleDetail.bind(null, record),
      }
    ]
  }
  /**
   * 详情
   */
  function handleDetail(record: Recordable) {
    openModal(true, {
      record,
      isUpdate: true,
      showFooter: false,
    });
  }

/*  onMountedOrActivated(()=>{
    let at = departmentId.value;
    departmentId.value = "fjf";
    departmentId.value = at;
  })*/


  //表单提交事件
  async function handleSubmit(v) {

    (selectedRowKeys.value = []) && reload();

  }
  function handleSuccess(){

  }
</script>

<style lang="less" scoped>
  /** 时间和数字输入框样式 */
  :deep(.ant-input-number){
    width: 100%
  }

  :deep(.ant-calendar-picker){
    width: 100%
  }
</style>
